package com.xl.utils.util.qiniuyun.service;

import com.qiniu.common.QiniuException;
import com.qiniu.http.Response;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.InputStream;

/**
 * @author xionglin
 * @date 2019/10/26 18:06
 * @Description 抽象上传类型
 */
public interface IQiniuyunService {

    /**
     * 文件上传
     * @param file
     * @param fileName
     * @return
     * @throws QiniuException
     */
    Response uploadFile(File file, String fileName) throws QiniuException;

    /**
     * 文件流上传
     * @param inputStream
     * @param fileName
     * @return
     * @throws QiniuException
     */
    Response uploadFile(InputStream inputStream, String fileName) throws QiniuException;

    /**
     * MultipartFile上传
     * @param multipartFile
     * @return 文件地址
     * @throws QiniuException
     */
    String uploadFile(MultipartFile multipartFile) throws QiniuException;

    /**
     * MultipartFile上传
     * @param multipartFile
     * @param onlyUrl true：返回的就是文件的地址   false：返回的是七牛的Response的响应体
     * @return
     * @throws QiniuException
     */
    String uploadFile(MultipartFile multipartFile, boolean onlyUrl) throws QiniuException;

    /**
     * 删除文件
     * @param key
     * @return
     * @throws QiniuException
     */
    Response delete(String key) throws QiniuException;
}
